#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright @ 2014 OPS, Qunar Inc. (qunar.com)
#
# Author: tingfang.bao <tingfang.bao@qunar.com>
# DateTime: 15-3-11 下午12:06
from wtforms import Form, BooleanField, StringField, PasswordField, validators
from flask import Flask, request


class RegistrationForm(Form):
    username = StringField("username", [validators.Length(min=4, max=25)])
    email = StringField("email", [validators.Length(min=6, max=35)])
    password = PasswordField("password", [
        validators.DataRequired(message='password required'),
        validators.EqualTo('confirm_password', message='Passwords must match')
    ])
    confirm_password = PasswordField('confirm_password')
    accept = BooleanField('accept', [validators.DataRequired()])


app = Flask(__name__)


@app.route('/register', methods=['GET', 'POST'])
def index():
    form = RegistrationForm(request.form)

    if request.method == 'POST' and form.validate():
        print form.username.data
        print form.email.data
        print form.password.data
        print form.confirm_password.data
        print form.accept.data
    return 'ok'


if __name__ == '__main__':
    app.run(debug=True)